<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/6/25
 * Time: 10:03
 */
namespace app\api\validate;

use think\Validate;

class Address extends Validate{
    protected $rule = [
        'name' => 'require',
        'gender' => 'require|in:1,2',
        'mobile' => ['regex'=>'/^1(?:3\d|4[4-9]|5[0-35-9]|6[67]|7[013-8]|8\d|9\d)\d{8}$/'],
        'address' => 'require|max:30',
        'housenumber' => 'require|max:30',
        'label' => 'require',
        'isdefault' => 'require|in:1,0',
    ];
    protected $message  =   [
        'name.require'      => '姓名必须',
        'gender.require'    => '性别必须',
        'gender.in'         => '性别错误',
        'mobile.regex'      => '号码不正确',
        'address.require'   => '地址必须',
        'address.max'       => '地址最多30个字',
        'housenumber.require'=> '门牌号必须',
        'housenumber.max'   => '门牌号最多30个字',
        'label.require'     => '标签必须',
        'isdefault.require' => '默认地址必须',
        'isdefault.in'      => '默认地址错误',
    ];
}